package com.ruoyi.system.service.impl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.ruoyi.system.domain.SysSupplier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysSupplierMapper;
import com.ruoyi.system.service.ISysSupplierService;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.ServletUtils;

/**
 * 供应商模拟Service业务层处理
 *
 * @author ygx
 * @date 2020-06-18
 */
@Service
public class SysSupplierServiceImpl implements ISysSupplierService
{
    @Autowired
    private SysSupplierMapper sysSupplierMapper;

    /**
     * 查询供应商模拟
     *
     * @param supplierId 供应商模拟ID
     * @return 供应商模拟
     */
    @Override
    public SysSupplier selectSysSupplierById(Long supplierId)
    {
        return sysSupplierMapper.selectSysSupplierById(supplierId);
    }


    /**
     * 查询供应商模拟列表
     *
     * @param sysSupplier 供应商模拟
     * @return 供应商模拟
     */
    @Override
    public List<SysSupplier> selectSysSupplierList(SysSupplier sysSupplier)
    {
        return sysSupplierMapper.selectSysSupplierList(sysSupplier);
    }

    /**
     * 查询所有供应商
     *
     * @return 供应商列表
     */

    @Override
    public List<SysSupplier> selectSupplierAll()
    {
        return selectSysSupplierList(new SysSupplier());
    }

    /**
     * 根据用户ID查询供应商
     *
     * @param userId 用户ID
     * @return 角色列表
     */
    @Override
    public List<SysSupplier> selectSuppliersByUserId()
    {
    	HttpServletRequest request = ServletUtils.getRequest();
    	Long userId = Long.valueOf(request.getHeader(Constants.CURRENT_ID));
    	return sysSupplierMapper.selectSuppliersByUserId(userId);
    };

    /**
     * 根据用户ID查询供应商
     *
     * @param userId 用户ID
     * @return 角色列表
     */
    @Override
    public List<SysSupplier> selectSuppliersByUserId(Long userId)
    {
    	return sysSupplierMapper.selectSuppliersByUserId(userId);
    }

    @Override
    public List<SysSupplier> selectSysFactorySupplierList(SysSupplier sysSupplier) {
        return sysSupplierMapper.selectSysFactorySupplierList(sysSupplier);
    }

    ;

    /**
     * 新增供应商模拟
     *
     * @param sysSupplier 供应商模拟
     * @return 结果
     */
    @Override
    public int insertSysSupplier(SysSupplier sysSupplier)
    {
        return sysSupplierMapper.insertSysSupplier(sysSupplier);
    }

    /**
     * 修改供应商模拟
     *
     * @param sysSupplier 供应商模拟
     * @return 结果
     */
    @Override
    public int updateSysSupplier(SysSupplier sysSupplier)
    {
        return sysSupplierMapper.updateSysSupplier(sysSupplier);
    }

    /**
     * 删除供应商模拟对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteSysSupplierByIds(String ids)
    {
        return sysSupplierMapper.deleteSysSupplierByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除供应商模拟信息
     *
     * @param supplierId 供应商模拟ID
     * @return 结果
     */
    public int deleteSysSupplierById(Long supplierId)
    {
        return sysSupplierMapper.deleteSysSupplierById(supplierId);
    }
}
